namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmNhDmEditor : FormListEditor
    {
        private IContainer components;
        private LabelControl lblDvt;
        private LabelControl lblDvt_E;
        private LabelControl lblMa_Nh_Dm;
        private LabelControl lblTen_Nh_Dm;
        private LabelControl lblTen_Nh_DmE;
        private TextControl txtDvt;
        private TextControl txtDvt_E;
        private TextControl txtMa_Nh_Dm;
        private TextControl txtTen_Nh_Dm;
        private TextControl txtTen_Nh_DmE;

        public FormDmNhDmEditor()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            //ComponentResourceManager manager = new ComponentResourceManager(typeof(FormDmNhDmEditor));
            this.txtMa_Nh_Dm = new TextControl();
            this.lblMa_Nh_Dm = new LabelControl();
            this.txtTen_Nh_Dm = new TextControl();
            this.lblTen_Nh_Dm = new LabelControl();
            this.txtTen_Nh_DmE = new TextControl();
            this.lblTen_Nh_DmE = new LabelControl();
            this.lblDvt = new LabelControl();
            this.txtDvt = new TextControl();
            this.lblDvt_E = new LabelControl();
            this.txtDvt_E = new TextControl();
            base.SuspendLayout();
            base.txtMa_Loai3.FirstFilter = "Type = 'ND3'";
            base.txtMa_Loai3.Location = new Point(0x18c, 0x8a);
            base.txtMa_Loai3.Size = new Size(0x85, 20);
            base.txtMa_Loai3.TabIndex = 7;
            base.txtMa_Loai2.FirstFilter = "Type = 'ND2'";
            base.txtMa_Loai2.Location = new Point(0x103, 0x8a);
            base.txtMa_Loai2.Size = new Size(0x86, 20);
            base.txtMa_Loai2.TabIndex = 6;
            base.txtMa_Loai1.FirstFilter = "Type = 'ND1'";
            base.txtMa_Loai1.Location = new Point(0x7b, 0x8a);
            base.txtMa_Loai1.Size = new Size(0x85, 20);
            base.txtMa_Loai1.TabIndex = 5;
            base.lblPhan_Loai.Location = new Point(12, 0x8d);
            this.txtMa_Nh_Dm.CharacterCasing = CharacterCasing.Upper;
            this.txtMa_Nh_Dm.CheckTextSearched = false;
            this.txtMa_Nh_Dm.DisabledForeColor = Color.Empty;
            this.txtMa_Nh_Dm.Font = new Font("Arial", 8.25f);
            this.txtMa_Nh_Dm.Location = new Point(0x7b, 0x1c);
            this.txtMa_Nh_Dm.MaxLength = 0x20;
            this.txtMa_Nh_Dm.Name = "txtMa_Nh_Dm";
            this.txtMa_Nh_Dm.OldValue = null;
            this.txtMa_Nh_Dm.Size = new Size(0x85, 20);
            this.txtMa_Nh_Dm.TabIndex = 0;
            this.txtMa_Nh_Dm.UserTextLength = AppInstance.TextControlLength.ItemCode;
            this.txtMa_Nh_Dm.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtMa_Nh_Dm.Value = null;//manager.GetObject("txtMa_Nh_Dm.Value");
            this.lblMa_Nh_Dm.AutoSize = true;
            this.lblMa_Nh_Dm.Font = new Font("Arial", 8.25f);
            this.lblMa_Nh_Dm.Location = new Point(12, 0x1f);
            this.lblMa_Nh_Dm.Name = "lblMa_Nh_Dm";
            this.lblMa_Nh_Dm.Size = new Size(50, 14);
            this.lblMa_Nh_Dm.TabIndex = 4;
            this.lblMa_Nh_Dm.Text = "Mã nhóm";
            this.txtTen_Nh_Dm.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Nh_Dm.CheckTextSearched = false;
            this.txtTen_Nh_Dm.DisabledForeColor = Color.Empty;
            this.txtTen_Nh_Dm.Font = new Font("Arial", 8.25f);
            this.txtTen_Nh_Dm.Location = new Point(0x7b, 50);
            this.txtTen_Nh_Dm.MaxLength = 128;
            this.txtTen_Nh_Dm.Name = "txtTen_Nh_Dm";
            this.txtTen_Nh_Dm.OldValue = null;
            this.txtTen_Nh_Dm.Size = new Size(0x196, 20);
            this.txtTen_Nh_Dm.TabIndex = 1;
            this.txtTen_Nh_Dm.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Nh_Dm.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_Nh_Dm.Value = null;//manager.GetObject("txtTen_Nh_Dm.Value");
            this.lblTen_Nh_Dm.AutoSize = true;
            this.lblTen_Nh_Dm.Font = new Font("Arial", 8.25f);
            this.lblTen_Nh_Dm.Location = new Point(12, 0x35);
            this.lblTen_Nh_Dm.Name = "lblTen_Nh_Dm";
            this.lblTen_Nh_Dm.Size = new Size(0x36, 14);
            this.lblTen_Nh_Dm.TabIndex = 4;
            this.lblTen_Nh_Dm.Text = "Tên nhóm";
            this.txtTen_Nh_DmE.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtTen_Nh_DmE.CheckTextSearched = false;
            this.txtTen_Nh_DmE.DisabledForeColor = Color.Empty;
            this.txtTen_Nh_DmE.Font = new Font("Arial", 8.25f);
            this.txtTen_Nh_DmE.Location = new Point(0x7b, 0x48);
            this.txtTen_Nh_DmE.MaxLength = 128;
            this.txtTen_Nh_DmE.Name = "txtTen_Nh_DmE";
            this.txtTen_Nh_DmE.OldValue = null;
            this.txtTen_Nh_DmE.Size = new Size(0x196, 20);
            this.txtTen_Nh_DmE.TabIndex = 2;
            this.txtTen_Nh_DmE.UserTextLength = AppInstance.TextControlLength.ItemDescription;
            this.txtTen_Nh_DmE.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtTen_Nh_DmE.Value = null;//manager.GetObject("txtTen_Nh_DmE.Value");
            this.lblTen_Nh_DmE.AutoSize = true;
            this.lblTen_Nh_DmE.Font = new Font("Arial", 8.25f);
            this.lblTen_Nh_DmE.Location = new Point(12, 0x4b);
            this.lblTen_Nh_DmE.Name = "lblTen_Nh_DmE";
            this.lblTen_Nh_DmE.Size = new Size(0x4a, 14);
            this.lblTen_Nh_DmE.TabIndex = 4;
            this.lblTen_Nh_DmE.Text = "Tên tiếng Anh";
            this.lblDvt.AutoSize = true;
            this.lblDvt.Font = new Font("Arial", 8.25f);
            this.lblDvt.Location = new Point(12, 0x61);
            this.lblDvt.Name = "lblDvt";
            this.lblDvt.Size = new Size(0x3b, 14);
            this.lblDvt.TabIndex = 0x25;
            this.lblDvt.Text = "Đơn vị tính";
            this.txtDvt.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtDvt.CheckTextSearched = false;
            this.txtDvt.DisabledForeColor = Color.Empty;
            this.txtDvt.Font = new Font("Arial", 8.25f);
            this.txtDvt.Location = new Point(0x7b, 0x5e);
            this.txtDvt.MaxLength = 20;
            this.txtDvt.Name = "txtDvt";
            this.txtDvt.OldValue = null;
            this.txtDvt.Size = new Size(0x85, 20);
            this.txtDvt.TabIndex = 3;
            this.txtDvt.UserTextLength = AppInstance.TextControlLength.InvoiceNumber;
            this.txtDvt.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtDvt.Value = null;//manager.GetObject("txtDvt.Value");
            this.lblDvt_E.AutoSize = true;
            this.lblDvt_E.Font = new Font("Arial", 8.25f);
            this.lblDvt_E.Location = new Point(12, 0x77);
            this.lblDvt_E.Name = "lblDvt_E";
            this.lblDvt_E.Size = new Size(0x6c, 14);
            this.lblDvt_E.TabIndex = 0x27;
            this.lblDvt_E.Text = "Đơn vị tính tiếng Anh";
            this.txtDvt_E.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.txtDvt_E.CheckTextSearched = false;
            this.txtDvt_E.DisabledForeColor = Color.Empty;
            this.txtDvt_E.Font = new Font("Arial", 8.25f);
            this.txtDvt_E.Location = new Point(0x7b, 0x74);
            this.txtDvt_E.MaxLength = 20;
            this.txtDvt_E.Name = "txtDvt_E";
            this.txtDvt_E.OldValue = null;
            this.txtDvt_E.Size = new Size(0x85, 20);
            this.txtDvt_E.TabIndex = 4;
            this.txtDvt_E.UserTextLength = AppInstance.TextControlLength.InvoiceNumber;
            this.txtDvt_E.UserTrimMode = AppInstance.TextControlTrimMode.All;
//            this.txtDvt_E.Value = null;//manager.GetObject("txtDvt_E.Value");
            base.AddTitleText = "Thêm mới nhóm định mức";
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x222, 0xac);
            base.Controls.Add(this.lblDvt_E);
            base.Controls.Add(this.txtDvt_E);
            base.Controls.Add(this.lblDvt);
            base.Controls.Add(this.txtDvt);
            base.Controls.Add(this.lblTen_Nh_DmE);
            base.Controls.Add(this.lblTen_Nh_Dm);
            base.Controls.Add(this.lblMa_Nh_Dm);
            base.Controls.Add(this.txtTen_Nh_DmE);
            base.Controls.Add(this.txtTen_Nh_Dm);
            base.Controls.Add(this.txtMa_Nh_Dm);
            base.EditTitleText = "Sửa nhóm định mức";
            base.FirstFreeCode = "ND1";
            base.Name = "FormDmNhDmEditor";
            base.SecondFreeCode = "ND2";
            this.Text = "Thêm mới nhóm định mức";
            base.ThirdFreeCode = "ND3";
            base.Controls.SetChildIndex(base.lblPhan_Loai, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai1, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai2, 0);
            base.Controls.SetChildIndex(base.txtMa_Loai3, 0);
            base.Controls.SetChildIndex(this.txtMa_Nh_Dm, 0);
            base.Controls.SetChildIndex(this.txtTen_Nh_Dm, 0);
            base.Controls.SetChildIndex(this.txtTen_Nh_DmE, 0);
            base.Controls.SetChildIndex(this.lblMa_Nh_Dm, 0);
            base.Controls.SetChildIndex(this.lblTen_Nh_Dm, 0);
            base.Controls.SetChildIndex(this.lblTen_Nh_DmE, 0);
            base.Controls.SetChildIndex(this.txtDvt, 0);
            base.Controls.SetChildIndex(this.lblDvt, 0);
            base.Controls.SetChildIndex(this.txtDvt_E, 0);
            base.Controls.SetChildIndex(this.lblDvt_E, 0);
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override bool OnSave()
        {
            DataRow localCurrentRow;
            if (string.IsNullOrEmpty(this.txtMa_Nh_Dm.Text))
            {
                MessageBox.Show("Chưa nhập mã nhóm định mức!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (string.IsNullOrEmpty(this.txtTen_Nh_Dm.Text))
            {
                MessageBox.Show("Chưa nhập tên nhóm định mức!", AppInstance.SoftwareName, MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return false;
            }
            if (base.NewChecked)
            {
                localCurrentRow = base.LocalTable.NewRow();
            }
            else
            {
                localCurrentRow = base.LocalCurrentRow;
            }
            localCurrentRow["Ma_Nh_Dm"] = this.txtMa_Nh_Dm.Value;
            localCurrentRow["Ten_Nh_Dm"] = this.txtTen_Nh_Dm.Value;
            localCurrentRow["Ten_Nh_DmE"] = this.txtTen_Nh_DmE.Value;
            localCurrentRow["Dvt"] = this.txtDvt.Value;
            localCurrentRow["Dvt_E"] = this.txtDvt_E.Value;
            localCurrentRow["Ma_Loai1"] = base.txtMa_Loai1.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            localCurrentRow["Ma_Loai2"] = base.txtMa_Loai2.Value;
            DmNhDmDataAccess access = new DmNhDmDataAccess();
            if (base.ShowMessage(localCurrentRow, access.SaveRow(base.NewChecked, localCurrentRow)))
            {
                return false;
            }
            if (base.NewChecked)
            {
                base.LocalTable.Rows.Add(localCurrentRow);
            }
            base.LocalCurrentRow = localCurrentRow;
            base.LocalTable.AcceptChanges();
            this.txtMa_Nh_Dm.Focus();
            return base.OnSave();
        }

        public override void OnShow()
        {
            this.txtMa_Nh_Dm.Value = base.LocalCurrentRow["Ma_Nh_Dm"];
            this.txtTen_Nh_Dm.Value = base.LocalCurrentRow["Ten_Nh_Dm"];
            this.txtTen_Nh_DmE.Value = base.LocalCurrentRow["Ten_Nh_DmE"];
            this.txtDvt.Value = base.LocalCurrentRow["Dvt"];
            this.txtDvt_E.Value = base.LocalCurrentRow["Dvt_E"];
            base.txtMa_Loai1.Value = base.LocalCurrentRow["Ma_Loai1"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.txtMa_Loai2.Value = base.LocalCurrentRow["Ma_Loai2"];
            base.OnShow();
        }
    }
}

